import type { AsyncTenantPackage, TenantSearchParams, TenantVO, Tenants } from '@/service/types/tenant';
import { request } from '@/service/request';

export function getPageList(params?: TenantSearchParams) {
  return request<Tenants.TenantVo>({
    url: '/system/tenant/list',
    method: 'get',
    params
  });
}

export function addTenant(data: TenantVO) {
  return request<TenantVO>({
    url: '/system/tenant',
    method: 'post',
    data,
    headers: {
      isEncrypt: true,
      'Content-Type': 'application/json'
    }
  });
}

export function editTenant(data: TenantVO) {
  return request({
    url: '/system/tenant',
    method: 'put',
    data
  });
}

export function delTenant(id: number | number[]) {
  return request({
    url: `/system/tenant/${id}`,
    method: 'delete'
  });
}

export function getTenant(id: number) {
  return request({
    url: `/system/tenant/${id}`,
    method: 'get'
  });
}

export function asyncTenantPakcage(params: AsyncTenantPackage) {
  return request({
    url: `/system/tenant/syncTenantPackage`,
    method: 'get',
    params
  });
}

export function changeStatus(data: any) {
  return request({
    url: `/system/tenant/changeStatus`,
    method: 'PUT',
    data
  });
}
